package demo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: liangyuanzhang
 * Date: 2025-1-10
 * Time: 13:05
 */
public class Animal {

    public String name;
    public int age;

    static {
        System.out.println("static :: Animal{ }");
    }

    {
        System.out.println("实例代码块 Animal{ }");

    }

    public Animal(String name, int age) {
        this.name = name;
        this.age = age;
        System.out.println("Animal()......");
    }

    /*public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }*/

    public void eat(){
        System.out.println(this.name + " 正在吃饭......");
    }

    @Override
    public String toString() {
        return "Animal{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
